<?php
/**
 * Created by PhpStorm.
 * User: dapeng
 * Date: 2018/10/18
 * Time: 下午2:24
 */

namespace app\models\Project_2_0;


use Core\Model;

class Cases extends Model
{

    //查全部
    function findAll(){

        $sql = "select * from t_case where 1=1 ";
        return $this->db->fetch_sql($sql);

    }

    /**
     * 按条件查询
     * @param $option
     * @param $content
     * @return mixed
     */
    function search($option,$content){
        $sql = "select  * from t_case where $option like '%$content%' ";
        return $this->db->fetch_sql($sql);

    }

    /**
     * 添加案件
     * @param $dealer 承办人
     * @param $name 案件号
     * @param $except 计划完成时间
     * @param $status 状态
     * @return mixed
     */
    function add($dealer,$name,$except,$status){
$date = date('Y-m-d H:i:s');

        $sql = "insert into t_case(`dealer`,`Name`,`receive_date`,`except_date`,`status`)
        VALUES ('$dealer','$name','$date','$except','$status');";
        return $this->db->fetch_sql($sql);
    }

    function lists($cc,$page){
        $sql = "select * from t_case ORDER BY c_id  limit $cc,$page";
        return $this->db->fetch_sql($sql);
    }

    function count_page(){
        $sql = "select count(*) from t_case";
        return $this->db->fetch_sql($sql);
    }

    function edit($id){
        $sql = "select * from t_case where c_id=$id ";
        return $this->db->fetch_sql($sql);
    }

    function update($dealer,$Name,$receive_date,$except_date,$status,$finish_date,$id){
        $sql = "update t_case set dealer='$dealer',Name='$Name',`receive_date`='$receive_date' ,`except_date`='$except_date',`status`='$status',`finish_date`='$finish_date' where c_id = '$id';";
        return $this->db->fetch_sql($sql);
    }
    function del($id){
        $sql = "delete from t_case where c_id = '$id'";
        return $this->db->fetch_sql($sql);
    }

}